|
|
|
|
|
|
|
Start this exercise by loading the REPLDEMO.VBP project into Visual Basic 5. Add a command button to the form REPLDEMO.FRM. Set the Name property of this button to cmdKeepLocal, and its Caption to &Keep Local. Now add the code in Listing 20.5 to the cmdKeepLocal_Click event. |
|
|
|
|
|
|
|
|
Listing 20.5. The Visual Basic 5 code to keep a table object from replicating. |
|
|
|
|
|
|
|
|
Private Sub cmdKeepLocal_Click()
Dim dbMaster As Database
Dim LocalProperty As Property
Dim KeepTab As Object
Dim repProperty As Property
'Open the database in exclusive mode
Set dbMaster = OpenDatabase("c:\tysdbvb5\source\data\keeploc.mdb", True)
Set KeepTab = dbMaster.TableDefs("Authors")
Set LocalProperty = dbMaster.CreateProperty("KeepLocal", dbText, "T")
KeepTab.Properties.Append LocalProperty
KeepTab.Properties("Keeplocal") = "T"
MsgBox "The Authors table is set to not replicate"
'Create and set the replicable property
Set repProperty = dbMaster.CreateProperty("Replicable", dbText, "T")
dbMaster.Properties.Append repProperty
dbMaster.Properties("Replicable") = "T"
'Display a message box
MsgBox "You have created a Design Master out of KEEPLOC.MDB!"
dbMaster.MakeReplica "c:\tysdbvb5\source\data\copykl.mdb", "Replica of " &
"dbMaster"
dbMaster.Close
MsgBox "You have created a copy of KEEPLOC.MDB"
End Sub |
|
|
|
|
|
|
|
|
This code first opens our database, KEEPLOC.MDB, and sets the KeepLocal property of the Authors table to T. Note that the KeepLocal property must be set before the Design Master is created. The program then turns KEEPLOC.MDB into a Design Master, and creates a replica named COPYKL.MDB. |
|
|
|
|
|
|
|
|
Now run the application and select the Keep Local Command button. You are prompted with a Message Box when the KeepLocal property is set to T for the Authors table, when the |
|
|
|
|
|